package com.blue.spring.convertor;

import java.time.LocalTime;

import org.springframework.core.convert.converter.Converter;

/**
 * 字符串转化为本地时间
 * 
 * @author zhengj
 * @since 1.0 2016年7月16日
 */
public class StringToLocalTimeConvertor implements Converter<String, LocalTime>
{
	public StringToLocalTimeConvertor()
	{
	}

	@Override
	public LocalTime convert(String text)
	{
		if (text == null || text.isEmpty())
			return null;

		if (text.length() > 8)
			text = text.substring(text.length() - 8);

		return LocalTime.parse(text);
	}
}
